package pers.wz.provider.service;

import org.springframework.stereotype.Service;
import pers.wz.api.IUserService;
import pers.wz.pojo.User;
import pers.wz.provider.anno.RpcService;

import java.util.HashMap;
import java.util.Map;

@RpcService
@Service
public class UserServiceImpl implements IUserService {
    Map<Integer, User> map = new HashMap<>();

    @Override
    public User getById(int id) {
        if (map.size() == 0) {
            User user1 = new User(1, "lisi");
            User user2 = new User(2, "zhangsan");
            map.put(user1.getId(), user1);
            map.put(user2.getId(), user2);
        }
        return map.get(id);
    }
}
